<%@page import="java.util.List"%>
<%@page import="model.CategoryImp"%>
<%@page import="model.entity.Category"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
 <script>
      function ConfirmDelete()
{
  var x = confirm("Are you sure you want to delete?");
  if (x)
      return true;
  else
    return false;
}
  </script>
  
<div class="container_12">
  
	<h2>Child Category</h2>
<p class="message1">
<%
                            String message = request.getAttribute("messcategory")==null ? "":request.getAttribute("messcategory").toString();
                        out.println(message);
%>
        </p>
                
            
    <div class="clearfix">&nbsp;</div>
            	
    <table width="100%" border="0" cellpadding="0" cellspacing="0">
    
        <tbody>
        <tr class="even">
            <th width="10%" scope="col">Id</th>
            <th width="30%" scope="col">Name</th>
            <th width="20%" scope="col">Parent name</th> 
            <th width="20%" scope="col">Product</th> 
            <th width="20%" scope="col">Option</th>
        </tr>
<%
CategoryImp cim = new CategoryImp();  
Category cat = new Category();
                      
List<Category> listcat = cim.ChildCategory();
        for(Category dm: listcat)
                       {
            int i = dm.getParentid();
            cat = cim.DetailCategory(i);
%>
        <tr>
        
           
            <td scope="col"><%= dm.getCategoryid() %></td>
            <td scope="col"><%= dm.getCategoryname() %></td>
            <td scope="col"><%= cat.getCategoryname() %></td>
            <td scope="col">
                <form action="<c:url value="<%= "/admin/product" %>" ></c:url>" method="GET">
                                <input type="text" name="categoryid" hidden="true" value="<%= dm.getCategoryid() %>"/>
                                <a href="<c:url value="<%= "/admin/product" + dm.getCategoryid() %>"></c:url>"><input type="submit" value="View Product" class="submit"/></a>
                            </form>
                
            
            </td>
            <td scope="col">
                <form action="<c:url value="<%= "/admin/product" %>"/>" method="POST">
                <a onclick="return ConfirmDelete();" href="<c:url value="<%= "/admin/category/delete/" + dm.getCategoryid() %>"> 
                       
                   </c:url>"><img src="<c:url value="/views/admin/images/icondock/page_white_delete.png"/>" title="Delete"/></a> 
                  
                   <a href="<c:url value="<%= "/admin/category/edit/" + dm.getCategoryid() %>">
                         
                       
                      </c:url>"/><img title="Edit" src="<c:url value="/views/admin/images/icondock/page_white_edit.png"/>"/></a>
                      
            </form>     
                 
                  
            </td>
        </tr>
<%}%>       
        
     
    </tbody></table>
    
    <!-- END TABULAR DATA EXAMPLE -->
      
           
           
            

           
           <div class="clearfix">&nbsp;</div>
           
           
              
          
</div>
